﻿//-----------------------------------------------------------------------
// <copyright file="Settings.cs" company="Craig Longford (deltawolf7@gmail.com)">
//     Copyright (c) Craig Longford. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Delta.Mercury.Business.Commerce
{
    using System;
    
    /// <summary>
    /// Mercury system settings
    /// </summary>
    [Serializable]
    public static class Settings
    {
        #region Mercury System Setting Methods
        /// <summary>
        /// Get next order number
        /// </summary>
        /// <returns>Next order number</returns>
        internal static int GetNextOrderNumber()
        {
            return int.Parse(Mercury.Business.Settings.GetSetting("MERCURY.NEXTORDERNUMBER"));
        }

        /// <summary>
        /// Update order number
        /// </summary>
        internal static void UpdateOrderNumber()
        {
            Setting setting = Setting.Load("MERCURY.NEXTORDERNUMBER");
            int number = int.Parse(setting.Value);
            number++;
            setting.Value = number.ToString();
            setting.Save();
        }

        /// <summary>
        /// Get order number prefix
        /// </summary>
        /// <returns>Order number prefix</returns>
        internal static string GetOrderNumberPrefix()
        {
            return Mercury.Business.Settings.GetSetting("MERCURY.ORDERNUMBERPREFIX");
        }

        /// <summary>
        /// Get order number suffix
        /// </summary>
        /// <returns>Order number suffix</returns>
        internal static string GetOrderNumberSuffix()
        {
            return Mercury.Business.Settings.GetSetting("MERCURY.ORDERNUMBERSUFFIX");
        }

        /// <summary>
        /// Get vat rate
        /// </summary>
        /// <returns>VAT Rate Value</returns>
        internal static decimal GetVATRate()
        {
            return decimal.Parse(Mercury.Business.Settings.GetSetting("MERCURY.VATRATE"));
        }
        #endregion
    }
}
